package utils;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

public class Graphic {

	private DefaultCategoryDataset dataset;
	private JFreeChart chart;
	private ChartFrame frame;

	public static void main(String[] args) {

		// try {
		// ChartUtilities.saveChartAsJPEG(new File("C:chart.jpg"), chart, 500,
		// 300);
		// } catch (IOException e) {
		// System.err.println("Problem occurred creating chart.");
		// }
	}

	public Graphic() {
		this.dataset = new DefaultCategoryDataset();
	}

	public void setValues(int cost, String transformationName, String rowKey) {
		this.dataset.setValue(cost, rowKey, transformationName);
	}

	public void displayGraphic(String title, String bottomTitle,
			String verticalTitle) {
		this.chart = ChartFactory.createBarChart3D(title, bottomTitle,
				verticalTitle, this.dataset, PlotOrientation.VERTICAL, true,
				true, false);

		frame = new ChartFrame("First", chart);
		frame.pack();
		frame.setVisible(true);
	}

}
